<%= content_tag :div, { class: 'fields', 'data-object-name' => f.object_name } do %>

  <% remove_able = true if local_assigns[:remove_able].nil? %>
  <% if remove_able == false %>
    <%= content_tag(:span, "#{t('ransack.advanced_search.condition_group.match')}
      #{f.combinator_select({}, {class: 'form-control input-sm'})}
      #{t('ransack.advanced_search.condition_group.match_condition')}", nil, false) %>
  <% else %>
    <%= content_tag(:span, "#{t('ransack.advanced_search.condition_group.match')}
      #{f.combinator_select({}, {class: 'form-control input-sm'})} #{t('ransack.advanced_search.condition_group.match_condition')}
      #{button_to_remove_fields}", nil, false) %>
  <% end %>

  <% condition_fields = f.condition_fields do |c| %>
    <%= render 'ransack_advanced_search/condition_fields', f: c %>
  <% end %>
  <%= condition_fields %>
  <% if condition_fields.empty? %>
    <%= f.send("condition_fields", f.object.send("build_condition"), child_index: "new_condition") do |builder| %>
      <%= render 'ransack_advanced_search/condition_fields', f: builder %>
    <% end %>
  <% end %>

  <%= button_to_add_fields '', f, :condition %>

  <%= f.grouping_fields do |g| %>
    <%= render partial: 'ransack_advanced_search/grouping_fields',
               locals: { f: g, remove_able: true } %>
  <% end %>

<% end %>
